/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AtendimentoMedico.java
 *
 * Created on 16/06/2012, 16:49:32
 */
package View;

import Dao.SistemaDAO;
import Modelo.Consulta;
import Modelo.Internacao;
import Modelo.Paciente;
import Modelo.TabelaAtmMedico;
import Util.PAPUtil;
import java.util.ArrayList;

/**
 *
 * @author Rafael
 */
public class AtendimentoMedico extends javax.swing.JFrame {
    LocAtmMedico telaAnterior = new LocAtmMedico();
    SistemaDAO sisDao = new SistemaDAO();
    
    /** Creates new form AtendimentoMedico */
    public AtendimentoMedico(LocAtmMedico atmMedico) {
        initComponents();
        String[] group = null;
        String[] order = null;
        
        telaAnterior = atmMedico;
        Paciente paciente = new Paciente();//novo Paciente
        ArrayList<Paciente> listaGlobal = new ArrayList<Paciente>();
        listaGlobal = (ArrayList<Paciente>) sisDao.listaCondicao("Modelo.Paciente", 
                String.valueOf(telaAnterior.obj.getPacienteIdpaciente()), group, order, "idpaciente", 0);
        paciente = listaGlobal.get(0);
        
        jTxtNome.setText(paciente.getNome());
        jTxtNome.setEditable(false);// para não poder editar
        jTxtData.setText(PAPUtil.toDataNormal(telaAnterior.obj.getDataConsulta()));
        jTxtData.setEditable(false);// para não poder editar
        jTxtHora.setText(PAPUtil.toHoraNormal(telaAnterior.obj.getHora()));
        jTxtHora.setEditable(false);// para não poder editar
        jTaDescricao.setText(telaAnterior.obj.getDescricao());
        
        
    }
    public AtendimentoMedico(Consulta obj){
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jBtnovoReceita = new javax.swing.JButton();
        jBtNovoInternacao = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jBtnovoExame = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTaDescricao = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jTxtNome = new javax.swing.JTextField();
        jBtok = new javax.swing.JButton();
        jBtCancelar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTxtData = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTxtHora = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setBackground(new java.awt.Color(255, 255, 255));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Atend.Médico"));

        jBtnovoReceita.setText("Receita");

        jBtNovoInternacao.setText("Internação");
        jBtNovoInternacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtNovoInternacaoActionPerformed(evt);
            }
        });

        jLabel1.setText("Descrição Do Atendimento:");

        jBtnovoExame.setText("Exame");
        jBtnovoExame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnovoExameActionPerformed(evt);
            }
        });

        jTaDescricao.setColumns(20);
        jTaDescricao.setRows(5);
        jScrollPane1.setViewportView(jTaDescricao);

        jLabel2.setText("Nome:");

        jBtok.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/V.png"))); // NOI18N
        jBtok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtokActionPerformed(evt);
            }
        });

        jBtCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/X.png"))); // NOI18N
        jBtCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtCancelarActionPerformed(evt);
            }
        });

        jLabel4.setText("Data:");

        jLabel5.setText("Hora:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jTxtData, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(94, 94, 94)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTxtHora, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
                            .addComponent(jTxtNome, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jBtCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jBtok, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jBtnovoExame)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jBtnovoReceita)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jBtNovoInternacao))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(141, 141, 141))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTxtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTxtData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jTxtHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtnovoExame)
                    .addComponent(jBtnovoReceita)
                    .addComponent(jBtNovoInternacao))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jBtCancelar, 0, 0, Short.MAX_VALUE)
                    .addComponent(jBtok, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Simbolo_med2.jpg"))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(151, Short.MAX_VALUE)
                .addComponent(jLabel3)
                .addGap(44, 44, 44)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(178, 178, 178)
                        .addComponent(jLabel3))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(53, Short.MAX_VALUE))
        );

        jMenu1.setText("Ações");
        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBtnovoExameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnovoExameActionPerformed
        // VERIFICAR ESTA PROGRAMAÇÂO
        /*CadExame cadexame = new CadExame(telaAnterior.obj,this); 
        this.setEnabled(false);
        cadexame.setVisible(true);*/
    }//GEN-LAST:event_jBtnovoExameActionPerformed

    private void jBtCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtCancelarActionPerformed
        telaAnterior.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_jBtCancelarActionPerformed

    private void jBtNovoInternacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtNovoInternacaoActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        CadInternacao cad = new CadInternacao(telaAnterior,this);
        cad.setVisible(true);
    }//GEN-LAST:event_jBtNovoInternacaoActionPerformed

    private void jBtokActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtokActionPerformed
        // TODO add your handling code here:
        Consulta con = new Consulta();
        con = telaAnterior.obj;
        con.setDescricao(jTaDescricao.getText());// caso el
        con.setStatusConsulta(true); // true é FINALIZADO
        sisDao.addUpObjeto(con);
        telaAnterior.setEnabled(true);
        
         
        this.dispose();
        this.setVisible(false);
    }//GEN-LAST:event_jBtokActionPerformed

    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtCancelar;
    private javax.swing.JButton jBtNovoInternacao;
    private javax.swing.JButton jBtnovoExame;
    private javax.swing.JButton jBtnovoReceita;
    private javax.swing.JButton jBtok;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTaDescricao;
    private javax.swing.JTextField jTxtData;
    private javax.swing.JTextField jTxtHora;
    private javax.swing.JTextField jTxtNome;
    // End of variables declaration//GEN-END:variables
}
